<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes"/>


<xsl:template name="index-3-style-and-script">



<STYLE type="text/css">
	#fanart1 { visibility: hidden; position: absolute; top: 93px; left: 874px; }
	#glow1 { visibility: hidden; position: absolute; top: 41px; left: 121px; }
	#fanart2 { visibility: hidden; position: absolute; top: 93px; left: 874px; }
	#glow2 { visibility: hidden; position: absolute; top: 41px; left: 289px; }
	#fanart3 { visibility: hidden; position: absolute; top: 93px; left: 874px; }
	#glow3 { visibility: hidden; position: absolute; top: 41px; left: 457px; }
	#fanart4 { visibility: hidden; position: absolute; top: 93px; left: 874px; }
	#glow4 { visibility: hidden; position: absolute; top: 41px; left: 625px; }
	#fanart5 { visibility: hidden; position: absolute; top: 93px; left: 874px; }
	#glow5 { visibility: hidden; position: absolute; top: 303px; left: 121px; }
	#fanart6 { visibility: hidden; position: absolute; top: 93px; left: 874px; }
	#glow6 { visibility: hidden; position: absolute; top: 303px; left: 289px; }
	#fanart7 { visibility: hidden; position: absolute; top: 93px; left: 874px; }
	#glow7 { visibility: hidden; position: absolute; top: 303px; left: 457px; }
	#fanart8 { visibility: hidden; position: absolute; top: 93px; left: 874px; }
	#glow8 { visibility: hidden; position: absolute; top: 303px; left: 625px; }

.title{font-size: 14pt; color: #ffffff; line-height: 15px; font-family: Arial; height: 54px;}
.info{font-size: 10pt; color: #b5b4b2; line-height: 15px; font-family: Arial; font-weight:bold;}
.text{font-size: 10pt; color: #ffffff; line-height: 15px; font-family: Arial;}
.filter {font-size: 15pt; font-weight: normal; color: #999999; line-height: 2px; font-family: Arial;}
a {text-decoration: none;}
img {border: 0;}
</STYLE>

<script type="text/javascript" src="pictures/passit.js">&#160;</script>


<!-- FILTER SCRIPT START -->


<script>
var alphaim=[ 
  ",",
  ",",
  <xsl:for-each select="library/category[@name='Title']/index">
    "<xsl:value-of select="@name" />,<xsl:value-of select="." />.html",
  </xsl:for-each>
  ",",
  ","
];

var genreim=[
  ",",
  ",",
  <xsl:for-each select="library/category[@name='Other']/index">
    "<xsl:value-of select="@name" />,<xsl:value-of select="." />.html",
  </xsl:for-each>
  <xsl:for-each select="library/category[@name='Genres']/index">
    "<xsl:value-of select="@name" />,<xsl:value-of select="." />.html",
  </xsl:for-each>
  ",",
  ","
];


var alphaid = 2;
var genrecnt = 2;
var flag = 1;

<xsl:choose>
  <xsl:when test="//index[@current='true']/@name = '09'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'A'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'B'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'C'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'D'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'E'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'F'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'G'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'H'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'I'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'J'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'K'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'L'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'M'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'N'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'O'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'P'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'Q'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'R'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'S'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'T'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'U'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'V'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'W'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'X'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'Y'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'Z'">flag = 0</xsl:when>

<!-- testing for these genres is not necessary since they fall under 'otherwise' section -->
  <xsl:when test="//index[@current='true']/@name = 'All'">flag = 1</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'HD'">flag = 1</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'TV Shows'">flag = 1</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'Movies'">flag = 1</xsl:when>
  <xsl:when test="//index[@current='true']/@name =' Trailers'">flag = 1</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'New'">flag = 1</xsl:when>

  <xsl:when test="//index[@current='true']/@name = 'Action'">flag = 1</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'Comedy'">flag = 1</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'Animation'">flag = 1</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'Documentary'">flag = 1</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'Drama'">flag = 1</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'Fantasy'">flag = 1</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'Other'">flag = 1</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'Sci-Fi'">flag = 1</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'Thriller'">flag = 1</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'Reality-TV'">flag = 1</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'Horror'">flag = 1</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'Music'">flag = 1</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'Top250'">flag = 1</xsl:when>

  <xsl:otherwise>flag = 1</xsl:otherwise>
</xsl:choose>

var xon = index<xsl:value-of select="translate(//index[@current='true']/@name,'-&#x20;','_')" />
var yon = 0
var pagenum = 1

var xon = [
  "",
  <xsl:for-each select="library/movies/movie[@isTrailer != 'true']">
    <xsl:choose>
      <xsl:when test="count(files/file) > 1">
        "<xsl:value-of select='baseFilename' />,<xsl:value-of select="baseFilename" />.playlist.jsp",
      </xsl:when>
      <xsl:otherwise>
        "<xsl:value-of select='baseFilename' />,<xsl:value-of select="files/file[1]/fileURL" />",
      </xsl:otherwise>
    </xsl:choose>
  </xsl:for-each>
  ""
];

//

// moves the letters left and right 
function alphaud(x)
{
  var len = alphaim.length
  var last = len - 2
  var twoItems, prevItems, twoprevItems, nextItems, twonextItems

  if (alphaid+x == last) { alphaid = 2 }
  else if (alphaid+x == 1) { alphaid = last - 1 }
  else { alphaid = alphaid+x }

  twoItems = alphaim[alphaid].split(",")
  prevItems = alphaim[alphaid-1].split(",")
  twoprevItems = alphaim[alphaid-2].split(",")
  nextItems = alphaim[alphaid+1].split(",")
  twonextItems = alphaim[alphaid+2].split(",")

  document.getElementById('twoup').firstChild.nodeValue = twoprevItems[0];
  document.getElementById('twoup').attributes[0].nodeValue = twoprevItems[1];

  document.getElementById('previ').firstChild.nodeValue = prevItems[0];
  document.getElementById('previ').attributes[0].nodeValue = prevItems[1];

  document.getElementById('change').firstChild.nodeValue = twoItems[0];
  document.getElementById('change').attributes[0].nodeValue = twoItems[1];

  document.getElementById('next').firstChild.nodeValue = nextItems[0];
  document.getElementById('next').attributes[0].nodeValue = nextItems[1]; 

  document.getElementById('twodown').firstChild.nodeValue = twonextItems[0];
  document.getElementById('twodown').attributes[0].nodeValue = twonextItems[1];
}

// moves the genres left and right
function genrelist(x)
{
  var glen = genreim.length
  var glast = glen - 2
  var genreItems, prevgenre, nextgenre, twoprevgenre, twonextgenre

  if (genrecnt+x == glast) { genrecnt = 2 }
  else if (genrecnt+x == 1) { genrecnt = glast - 1 }
  else { genrecnt = genrecnt+x }

  genreItems = genreim[genrecnt].split(",")
  prevgenre = genreim[genrecnt-1].split(",")
  nextgenre = genreim[genrecnt+1].split(",")
  twoprevgenre = genreim[genrecnt-2].split(",")
  twonextgenre = genreim[genrecnt+2].split(",")

  document.getElementById('twoup').firstChild.nodeValue = twoprevgenre[0];
  document.getElementById('twoup').attributes[0].nodeValue = twoprevgenre[1];

  document.getElementById('previ').firstChild.nodeValue = prevgenre[0];
  document.getElementById('previ').attributes[0].nodeValue = prevgenre[1];

  document.getElementById('change').firstChild.nodeValue = genreItems[0];
  document.getElementById('change').attributes[0].nodeValue = genreItems[1];

  document.getElementById('next').firstChild.nodeValue = nextgenre[0];
  document.getElementById('next').attributes[0].nodeValue = nextgenre[1]; 

  document.getElementById('twodown').firstChild.nodeValue = twonextgenre[0];
  document.getElementById('twodown').attributes[0].nodeValue = twonextgenre[1];
}

// change the list to letters 
function loadletter()
{
  var twoItems, prevItems, twoprevItems, nextItems, twonextItems

  flag = 0
  alphaid = 2
  twoItems = alphaim[alphaid].split(",")
  prevItems = alphaim[alphaid-1].split(",")
  twoprevItems = alphaim[alphaid-2].split(",")
  nextItems = alphaim[alphaid+1].split(",")
  twonextItems = alphaim[alphaid+2].split(",")

  document.getElementById('twoup').firstChild.nodeValue = twoprevItems[0];
  document.getElementById('twoup').attributes[0].nodeValue = twoprevItems[1];

  document.getElementById('previ').firstChild.nodeValue = prevItems[0];
  document.getElementById('previ').attributes[0].nodeValue = prevItems[1];

  document.getElementById('change').firstChild.nodeValue = twoItems[0];
  document.getElementById('change').attributes[0].nodeValue = twoItems[1];

  document.getElementById('next').firstChild.nodeValue = nextItems[0];
  document.getElementById('next').attributes[0].nodeValue = nextItems[1]; 

  document.getElementById('twodown').firstChild.nodeValue = twonextItems[0];
  document.getElementById('twodown').attributes[0].nodeValue = twonextItems[1]; 
  return false
}

// change the list to genres 
function loadgenre()
{
  var genreItems, prevgenre, nextgenre, twoprevgenre, twonextgenre

  flag = 1
  genrecnt = 2
  genreItems = genreim[genrecnt].split(",")
  prevgenre = genreim[genrecnt-1].split(",")
  nextgenre = genreim[genrecnt+1].split(",")
  twoprevgenre = genreim[genrecnt-2].split(",")
  twonextgenre = genreim[genrecnt+2].split(",")

  document.getElementById('twoup').firstChild.nodeValue = twoprevgenre[0];
  document.getElementById('twoup').attributes[0].nodeValue = twoprevgenre[1];

  document.getElementById('previ').firstChild.nodeValue = prevgenre[0];
  document.getElementById('previ').attributes[0].nodeValue = prevgenre[1];

  document.getElementById('change').firstChild.nodeValue = genreItems[0];
  document.getElementById('change').attributes[0].nodeValue = genreItems[1];

  document.getElementById('next').firstChild.nodeValue = nextgenre[0];
  document.getElementById('next').attributes[0].nodeValue = nextgenre[1]; 

  document.getElementById('twodown').firstChild.nodeValue = twonextgenre[0];
  document.getElementById('twodown').attributes[0].nodeValue = twonextgenre[1];

  return false
}

//
function upDown(x)
{
  if (flag == 0)
    alphaud(x)
  else
    genrelist(x)
  return false
}

//
function findItem( list, item )
{
  var result = -1;

  for ( var i = 0 ; i != list.length ; i++ )
  {
    if (list[i] == item) { return i; }
  }
  return result;
}

//
function initpage()
{
  var inittest = -1

  if (flag == 0)
  {
    inittest = findItem( alphaim,
      <xsl:choose>
        <xsl:when test="//index[@current='true']/@name = '09'">"09,Title_09_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'A'">"A,Title_A_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'B'">"B,Title_B_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'C'">"C,Title_C_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'D'">"D,Title_D_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'E'">"E,Title_E_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'F'">"F,Title_F_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'G'">"G,Title_G_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'H'">"H,Title_H_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'I'">"I,Title_I_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'J'">"J,Title_J_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'K'">"K,Title_K_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'L'">"L,Title_L_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'M'">"M,Title_M_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'N'">"N,Title_N_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'O'">"O,Title_O_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'P'">"P,Title_P_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Q'">"Q,Title_Q_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'R'">"R,Title_R_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'S'">"S,Title_S_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'T'">"T,Title_T_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'U'">"U,Title_U_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'V'">"V,Title_V_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'W'">"W,Title_W_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'X'">"X,Title_X_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Y'">"Y,Title_Y_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Z'">"Z,Title_Z_1.html"</xsl:when>
        <xsl:otherwise>"09,Title_09_1.html"</xsl:otherwise>
      </xsl:choose>
    )

    alphaid = inittest
    var twoItems = alphaim[alphaid].split(",")
    var prevItems = alphaim[alphaid-1].split(",")
    var twoprevItems = alphaim[alphaid-2].split(",")
    var nextItems = alphaim[alphaid+1].split(",")
    var twonextItems = alphaim[alphaid+2].split(",")

    document.getElementById('twoup').firstChild.nodeValue = twoprevItems[0];
    document.getElementById('twoup').attributes[0].nodeValue = twoprevItems[1];

    document.getElementById('previ').firstChild.nodeValue = prevItems[0];
    document.getElementById('previ').attributes[0].nodeValue = prevItems[1];

    document.getElementById('change').firstChild.nodeValue = twoItems[0];
    document.getElementById('change').attributes[0].nodeValue = twoItems[1];

    document.getElementById('next').firstChild.nodeValue = nextItems[0];
    document.getElementById('next').attributes[0].nodeValue = nextItems[1]; 

    document.getElementById('twodown').firstChild.nodeValue = twonextItems[0];
    document.getElementById('twodown').attributes[0].nodeValue = twonextItems[1]; 
  }
  else
  {
    inittest = findItem( genreim,
      <xsl:choose>
        <xsl:when test="//index[@current='true']/@name = 'All'">"All,Other_All_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'HD'">"HD,Other_HD_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'TV Shows'">"TV Shows,Other_TV Shows_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Movies'">"Movies,Other_Movies_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Trailers'">"Trailers,Other_Trailers_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'New'">"New,Other_New_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Action'">"Action,Genres_Action_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Comedy'">"Comedy,Genres_Comedy_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Animation'">"Animation,Genres_Animation_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Documentary'">"Documentary,Genres_Documentary_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Drama'">"Drama,Genres_Drama_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Fantasy'">"Fantasy,Genres_Fantasy_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Other'">"Other,Genres_Other_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Sci-Fi'">"Sci-Fi,Genres_Sci-Fi_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Thriller'">"Thriller,Genres_Thriller_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Reality-TV'">"Reality-TV,Genres_Reality-TV_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Horror'">"Horror,Genres_Horror_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Family'">"Family,Genres_Family_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Music'">"Music,Genres_Music_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Top250'">"Top250,Other_Top250_1.html"</xsl:when>
        <xsl:otherwise>"All,Other_All_1.html"</xsl:otherwise>
      </xsl:choose>
    )

    genrecnt = inittest
    var genreItems = genreim[genrecnt].split(",")
    var prevgenre = genreim[genrecnt-1].split(",")
    var nextgenre = genreim[genrecnt+1].split(",")
    var twoprevgenre = genreim[genrecnt-2].split(",")
    var twonextgenre = genreim[genrecnt+2].split(",")

    document.getElementById('twoup').firstChild.nodeValue = twoprevgenre[0];
    document.getElementById('twoup').attributes[0].nodeValue = twoprevgenre[1];

    document.getElementById('previ').firstChild.nodeValue = prevgenre[0];
    document.getElementById('previ').attributes[0].nodeValue = prevgenre[1];

    document.getElementById('change').firstChild.nodeValue = genreItems[0];
    document.getElementById('change').attributes[0].nodeValue = genreItems[1];

    document.getElementById('next').firstChild.nodeValue = nextgenre[0];
    document.getElementById('next').attributes[0].nodeValue = nextgenre[1]; 

    document.getElementById('twodown').firstChild.nodeValue = twonextgenre[0];
    document.getElementById('twodown').attributes[0].nodeValue = twonextgenre[1];
  }

  return false
}

</script>
<!-- FILTER SCRIPT END -->
<script type="text/javascript">
//
  var title = 1;
  var date = 1;
  var play = 1;
  var genre = 1;
  var runtime = 1;
  var director = 1;
  var credits = 1;
  var plot = 1;
  function bind() {
    if ( play == 1 ) play = document.getElementById('play');
    if ( title == 1 ) title = document.getElementById('title').firstChild;
    if ( date == 1 ) date = document.getElementById('date').firstChild;
    if ( genre == 1 ) genre = document.getElementById('genre').firstChild;
    if ( runtime == 1 ) runtime = document.getElementById('runtime').firstChild;
    if ( director == 1 ) director = document.getElementById('director').firstChild;
    if ( credits == 1 ) credits = document.getElementById('credits').firstChild;
    if ( plot == 1 ) plot = document.getElementById('plot').firstChild;
  }
  function show(x, jsp) {
    bind();
    title.nodeValue = document.getElementById('title'+x).firstChild.nodeValue;
    date.nodeValue = document.getElementById('date'+x).firstChild.nodeValue;
    genre.nodeValue = document.getElementById('genre'+x).firstChild.nodeValue;
    runtime.nodeValue = document.getElementById('runtime'+x).firstChild.nodeValue;
    director.nodeValue = document.getElementById('director'+x).firstChild.nodeValue;
    credits.nodeValue = document.getElementById('credits'+x).firstChild.nodeValue;
    plot.nodeValue = document.getElementById('plot'+x).firstChild.nodeValue;
    play.setAttribute('href', jsp);
    play.setAttribute('tvid', 'PLAY');
	document.styleSheets[1].cssRules[(x - 1) * 2].style.visibility = "visible"
	document.styleSheets[1].cssRules[(x - 1) * 2 + 1].style.visibility = "visible"
  }
  function hide(x) {
    bind();
    title.nodeValue = "&#160;";
    date.nodeValue = "&#160;";
    genre.nodeValue = "&#160;";
    runtime.nodeValue = "&#160;";
    director.nodeValue = "&#160;";
    credits.nodeValue = "&#160;";
    plot.nodeValue = "&#160;";
	play.setAttribute('tvid', '#');
	document.styleSheets[1].cssRules[(x - 1) * 2].style.visibility = "hidden"
	document.styleSheets[1].cssRules[(x - 1) * 2 + 1].style.visibility = "hidden"
  }
//
</script>

</xsl:template>

<xsl:template name="index-3-html">
 <!-- Localization -->
<xsl:variable name="All">All</xsl:variable>
<xsl:variable name="Movies">Movies</xsl:variable>
<xsl:variable name="ByGenre">by genre</xsl:variable>
<xsl:variable name="ByTitle">by title</xsl:variable>
<xsl:variable name="Categories">categories</xsl:variable>
<xsl:variable name="Television">television</xsl:variable>
<xsl:variable name="movies">movies</xsl:variable>
<xsl:variable name="Season">Season</xsl:variable>
<xsl:variable name="Specials">Specials</xsl:variable>
<xsl:variable name="ReleasedDate">Released date</xsl:variable>
<xsl:variable name="Genre">Genre</xsl:variable>
<xsl:variable name="Runtime">Runtime</xsl:variable>
<xsl:variable name="Director">Director</xsl:variable>
<xsl:variable name="Credits">Credits</xsl:variable>
<xsl:variable name="Description">Description</xsl:variable>

<!-- Links -->
<xsl:variable name="MusicLink">../index.htm</xsl:variable>
<xsl:variable name="PhotosLink">../index.htm</xsl:variable>
<xsl:variable name="PopappsLink">http://localhost.drives:8883/media_server.html</xsl:variable>
<xsl:variable name="SettingsLink">http://localhost.drives:8883/preferences.htm</xsl:variable>


<xsl:attribute name="background">pictures/popboxbg.png</xsl:attribute>
<xsl:attribute name="topmargin">38</xsl:attribute>
<xsl:attribute name="leftmargin">92</xsl:attribute>

<!-- FILTER HTML START -->
<xsl:for-each select="library/category[@name='Title']/index">
  <xsl:choose>
    <xsl:when test="@name = '09'"><a href="Title_09_1.html" tvid="1" /></xsl:when>
    <xsl:when test="@name = 'A'"><a href="Title_A_1.html" tvid="2" /></xsl:when>
    <xsl:when test="@name = 'B'"><a href="Title_B_1.html" tvid="22" /></xsl:when>
    <xsl:when test="@name = 'C'"><a href="Title_C_1.html" tvid="222" /></xsl:when>
    <xsl:when test="@name = 'D'"><a href="Title_D_1.html" tvid="3" /></xsl:when>
    <xsl:when test="@name = 'E'"><a href="Title_E_1.html" tvid="33" /></xsl:when>
    <xsl:when test="@name = 'F'"><a href="Title_F_1.html" tvid="333" /></xsl:when>
    <xsl:when test="@name = 'G'"><a href="Title_G_1.html" tvid="4" /></xsl:when>
    <xsl:when test="@name = 'H'"><a href="Title_H_1.html" tvid="44" /></xsl:when>
    <xsl:when test="@name = 'I'"><a href="Title_I_1.html" tvid="444" /></xsl:when>
    <xsl:when test="@name = 'J'"><a href="Title_J_1.html" tvid="5" /></xsl:when>
    <xsl:when test="@name = 'K'"><a href="Title_K_1.html" tvid="55" /></xsl:when>
    <xsl:when test="@name = 'L'"><a href="Title_L_1.html" tvid="555" /></xsl:when>
    <xsl:when test="@name = 'M'"><a href="Title_M_1.html" tvid="6" /></xsl:when>
    <xsl:when test="@name = 'N'"><a href="Title_N_1.html" tvid="66" /></xsl:when>
    <xsl:when test="@name = 'O'"><a href="Title_O_1.html" tvid="666" /></xsl:when>
    <xsl:when test="@name = 'P'"><a href="Title_P_1.html" tvid="7" /></xsl:when>
    <xsl:when test="@name = 'Q'"><a href="Title_Q_1.html" tvid="77" /></xsl:when>
    <xsl:when test="@name = 'R'"><a href="Title_R_1.html" tvid="777" /></xsl:when>
    <xsl:when test="@name = 'S'"><a href="Title_S_1.html" tvid="7777" /></xsl:when>
    <xsl:when test="@name = 'T'"><a href="Title_T_1.html" tvid="8" /></xsl:when>
    <xsl:when test="@name = 'U'"><a href="Title_U_1.html" tvid="88" /></xsl:when>
    <xsl:when test="@name = 'V'"><a href="Title_V_1.html" tvid="888" /></xsl:when>
    <xsl:when test="@name = 'W'"><a href="Title_W_1.html" tvid="9" /></xsl:when>
    <xsl:when test="@name = 'X'"><a href="Title_X_1.html" tvid="99" /></xsl:when>
    <xsl:when test="@name = 'Y'"><a href="Title_Y_1.html" tvid="999" /></xsl:when>
    <xsl:when test="@name = 'Z'"><a href="Title_Z_1.html" tvid="9999" /></xsl:when>
    <xsl:otherwise><a href="blank" tvid="blank" /></xsl:otherwise>
  </xsl:choose>
</xsl:for-each>

<xsl:for-each select="library/category[@name='Other']/index">
  <xsl:choose>
    <xsl:when test="@name = 'All'"><a href="Other_All_1.html" tvid="255" /></xsl:when>
    <xsl:when test="@name = 'HD'"><a href="Other_HD_1.html" tvid="43" /></xsl:when>
    <xsl:when test="@name = 'TV Shows'"><a href="Other_TV Shows_1.html" tvid="887" /></xsl:when>
    <xsl:when test="@name = 'Movies'"><a href="Other_Movies_1.html" tvid="668" /></xsl:when>
    <xsl:when test="@name = 'Trailers'"><a href="Other_Trailers_1.html" tvid="872" /></xsl:when>
    <xsl:when test="@name = 'New'"><a href="Other_New_1.html" tvid="639" /></xsl:when>
    <xsl:when test="//index[@current='true']/@name = 'Top250'">
      <a href="Other_Top250_1.html" tvid="807" />
    </xsl:when>
    <xsl:otherwise><a href="blank" tvid="blank" /></xsl:otherwise>
  </xsl:choose>
</xsl:for-each>

<xsl:for-each select="library/category[@name='Genres']/index">
  <xsl:choose>
    <xsl:when test="@name = 'Action'"><a href="Genres_Action_1.html" tvid="228" /></xsl:when>
    <xsl:when test="@name = 'Animation'"><a href="Genres_Animation_1.html" tvid="264" /></xsl:when>
    <xsl:when test="@name = 'Comedy'"><a href="Genres_Comedy_1.html" tvid="266" /></xsl:when>
    <xsl:when test="@name = 'Documentary'"><a href="Genres_Documentary_1.html" tvid="362" /></xsl:when>
    <xsl:when test="@name = 'Drama'"><a href="Genres_Drama_1.html" tvid="372" /></xsl:when>
    <xsl:when test="@name = 'Fantasy'"><a href="Genres_Fantasy_1.html" tvid="326" /></xsl:when>
    <xsl:when test="@name = 'Other'"><a href="Genres_Other_1.html" tvid="684" /></xsl:when>
    <xsl:when test="@name = 'Sci-Fi'"><a href="Genres_Sci-Fi_1.html" tvid="724" /></xsl:when>
    <xsl:when test="@name = 'Thriller'"><a href="Genres_Thriller_1.html" tvid="847" /></xsl:when>
    <xsl:when test="@name = 'Reality'"><a href="Genres_Reality_1.html" tvid="732" /></xsl:when>
    <xsl:when test="@name = 'Horror'"><a href="Genres_Horror_1.html" tvid="467" /></xsl:when>
    <xsl:when test="@name = 'Family'"><a href="Genres_Family_1.html" tvid="3264" /></xsl:when>
    <xsl:when test="@name = 'Music'"><a href="Genres_Music_1.html" tvid="687" /></xsl:when>
    <xsl:otherwise><a href="blank" tvid="blank" /></xsl:otherwise>
  </xsl:choose>
</xsl:for-each>
<!-- FILTER HTML END -->
<a>
	<xsl:attribute name="href"></xsl:attribute>
	<xsl:attribute name="tvid">#</xsl:attribute>
	<xsl:attribute name="id">play</xsl:attribute> 
	<xsl:attribute name="vod">playlist</xsl:attribute>
</a>


<table height="636" width="1085" border="0" cellspacing="0" cellpadding="0">
	<tr height="76">
		<td colspan="3" align="left" valign="top">
			<table border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td width="171"/>
					<td>
						<a href="../index.htm" name="yamj"><img src="pictures/videos.png" onfocussrc="pictures/button-hover.png"/></a>
					</td>
					<td width="21"/>
					<td>
						<a href="{$MusicLink}"><img src="pictures/music.png" onfocussrc="pictures/button-hover.png"/></a>
					</td>
					<td width="23"/>
					<td>
						<a href="{$PhotosLink}"><img src="pictures/photos.png" onfocussrc="pictures/button-hover.png"/></a>
					</td>
					<td width="35"/>
					<td>
						<a href="{$PopappsLink}"><img src="pictures/popapps.png" onfocussrc="pictures/button-hover.png"/></a>
					</td>
					<td width="40"/>
					<td>
						<a href="{$SettingsLink}" onkeyrightset="yamj"><img src="pictures/settings.png" onfocussrc="pictures/button-hover.png"/></a>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td valign="top">
			<table width="160" border="0" cellspacing="0" cellpadding="0">
				<tr><td height="26" colspan="2"/></tr>
				<tr>
					<td height="25" colspan="2" align="center">
						<a href="#" onclick="return upDown(-1)" onkeyupset="yamj" id="up" class="filter" name="upfilter" style="width:160">
							<img src="pictures/uparrow-off.png" onfocussrc="pictures/uparrow-on.png"/>
						</a>
					</td>
				</tr>
				<tr><td height="23" colspan="2"/></tr>
				<tr><td height="25" colspan="2" align="center"><a href="." class="filter" id="twoup" style="width:160">&#160;</a></td></tr>
				<tr><td height="23" colspan="2"/></tr>
				<tr><td height="25" colspan="2" align="center"><a href="." class="filter" id="previ" style="width:160">&#160;</a></td></tr>
				<tr><td height="23" colspan="2"/></tr>
				<tr>
					<td height="25" colspan="2" align="center">
						<a href="Other_All_1.html" class="filter" name="middle" id="change" style="width:160"><xsl:value-of select="$All"/></a>
					</td>
				</tr>
				<tr><td height="23" colspan="2"/></tr>
				<tr>
					<td height="25" colspan="2" align="center">
						<a href="Other_HD_1.html" class="filter" id="next" style="width:160">HD</a>
					</td>
				</tr>
				<tr><td height="23" colspan="2"/></tr>
				<tr>
					<td height="25" colspan="2" align="center">
						<a href="Other_Movies_1.html" class="filter" id="twodown" style="width:160"><xsl:value-of select="$Movies"/></a>
					</td>
				</tr>
				<tr><td height="23" colspan="2"/></tr>
				<tr>
					<td height="25" colspan="2" align="center">
						<a href="#" onclick="return upDown(1)" id="down" class="filter" onkeydownset="letter" style="width:160">
							<img src="pictures/downarrow-off.png" onfocussrc="pictures/downarrow-on.png"/>
						</a>
					</td>
				</tr>
				<tr><td height="23" colspan="2"/></tr>
				<tr>
					<td height="25" width="80" align="center">
						<a href="#" onclick="return loadgenre()" class="filter" style="width:80"><xsl:value-of select="$ByGenre"/></a>
					</td>
					<td align="center">
						<a href="#" onclick="return loadletter()" class="filter" name="letter" style="width:80"><xsl:value-of select="$ByTitle"/></a>
					</td>
				</tr>
				<tr><td height="23" colspan="2"/></tr>
				<tr>
					<td height="25" colspan="2" align="center">
						<a href="Categories.html" class="filter" onkeyupset="letter" style="width:160"><xsl:value-of select="$Categories"/></a>
					</td>
				</tr>
				<tr><td height="23" colspan="2"/></tr>
				<tr>
					<td height="25" colspan="2" align="center">
						<xsl:choose>
							<xsl:when test="contains(//index[@current='true']/@next,'TV Shows') and not(contains(//index[@current='true']/@next,'Year')) and not(contains(//index[@current='true']/@next,'Title')) and not(contains(//index[@current='true']/@next,'Rating')) and not(contains(//index[@current='true']/@next,'Genres')) or contains(//index[@current='true']/@next,'Set') and library/movies/movie/season != -1">
								<a href="Other_Movies_1.html" class="filter" style="width:160"><xsl:value-of select="$movies"/></a>
							</xsl:when>
							<xsl:otherwise>
								<a href="Other_TV Shows_1.html" class="filter" onkeydownset="upfilter" style="width:160"><xsl:value-of select="$Television"/></a>
							</xsl:otherwise>
						</xsl:choose>
					</td>
				</tr>
			</table>
		</td>
		<td>
			<table border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td height="24" width="625"/>
					<td>
						<a name="pgup" tvid="pgup" onkeyupset="yamj">
							<xsl:attribute name="href">
								<xsl:value-of select="library/category[@current='true']/index[@current='true']/@previous" />.html</xsl:attribute>
							<img src="pictures/uparrow-off.png" onfocussrc="pictures/uparrow-on.png"/>
						</a>
					</td>
					<td>
						<a>
							<xsl:attribute name="href">
								<xsl:value-of select="library/category[@current='true']/index[@current='true']/@next" />.html</xsl:attribute>
							<img src="pictures/downarrow-off.png" onfocussrc="pictures/downarrow-on.png"/>
						</a>
					</td>
					<td width="40"/>
				</tr>
				<tr>
					<td colspan="4" valign="top" align="left">
						<table border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td width="20"/>
								<td height="498" align="left" valign="top">
									<table border="0" cellpadding="9" cellspacing="0">
										<xsl:for-each select="library/movies/movie[position() mod $nbCols = 1]">
											<tr>
												<xsl:apply-templates select=".|following-sibling::movie[position() &lt; $nbCols]">
													<xsl:with-param name="gap" select="(position() - 1) * $nbCols" />
													<xsl:with-param name="currentIndex" select="$currentIndex" />
													<xsl:with-param name="lastIndex" select="$lastIndex" />
													<xsl:with-param name="lastGap" select="($nbLines - 1) * $nbCols" />
												</xsl:apply-templates>
											</tr>
										</xsl:for-each>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td height="24" width="625"/>
					<td>
						<a onkeydownset="pgup">
							<xsl:attribute name="href">
								<xsl:value-of select="library/category[@current='true']/index[@current='true']/@previous" />.html</xsl:attribute>
							<img src="pictures/uparrow-off.png" onfocussrc="pictures/uparrow-on.png"/>
						</a>
					</td>
					<td>
						<a onkeydownset="pgup" name="pgdn" tvid="pgdn">
							<xsl:attribute name="href">
								<xsl:value-of select="library/category[@current='true']/index[@current='true']/@next" />.html</xsl:attribute>
							<img src="pictures/downarrow-off.png" onfocussrc="pictures/downarrow-on.png"/>
						</a>
					</td>
					<td width="40"/>
				</tr>
			</table>
		</td>
		<td width="212" valign="top">
			<table border="0" cellspacing="0" cellpadding="0">
				<tr><td height="197"/></tr>
				<tr><td height="55" valign="top" class="title"><div id="title">&#160;</div></td></tr>
				<tr><td height="17" class="text"><div id="date">&#160;</div></td></tr>
				<tr><td height="16" class="text"><div id="genre">&#160;</div></td></tr>
				<tr><td height="16" class="text"><div id="runtime">&#160;</div></td></tr>
				<tr><td height="17" class="text"><div id="director">&#160;</div></td></tr>
				<tr><td height="48" valign="top" class="text"><div id="credits">&#160;</div></td></tr>
				<tr><td class="text"><div id="plot">&#160;</div></td></tr>
			</table>
		</td>
	</tr>
</table>

<xsl:for-each select="library/movies/movie">
	<div style="visibility:hidden">
		<xsl:attribute name="id">title<xsl:value-of select="position()"/></xsl:attribute>
				<xsl:choose>
					<xsl:when test="string-length(title)&lt;35">
						<xsl:value-of select="title"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="substring(title,1,32)"/>...
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="season > 0"><xsl:text> </xsl:text>
						<xsl:value-of select="$Season"/><xsl:text> </xsl:text><xsl:value-of select="season"/></xsl:when>
					<xsl:when test="season = 0"><xsl:text> </xsl:text><xsl:value-of select="$Specials"/></xsl:when>
				</xsl:choose>
	</div>
	<div style="visibility:hidden">
		<xsl:attribute name="id">date<xsl:value-of select="position()"/></xsl:attribute>
			<xsl:value-of select="$ReleasedDate"/>: 
				<xsl:if test="releaseDate='UNKNOWN'"><xsl:value-of select="year"/></xsl:if>
				<xsl:if test="releaseDate!='UNKNOWN'">
					<xsl:variable name="month">
						<xsl:choose>
							<xsl:when test="contains(substring-after(releaseDate,' '),'Jan')">Jan</xsl:when>
							<xsl:when test="contains(substring-after(releaseDate,' '),'Feb')">Feb</xsl:when>
							<xsl:when test="contains(substring-after(releaseDate,' '),'Mar')">Mar</xsl:when>
							<xsl:when test="contains(substring-after(releaseDate,' '),'Apr')">Apr</xsl:when>
							<xsl:when test="contains(substring-after(releaseDate,' '),'May')">May</xsl:when>
							<xsl:when test="contains(substring-after(releaseDate,' '),'Jun')">Jun</xsl:when>
							<xsl:when test="contains(substring-after(releaseDate,' '),'Jul')">Jul</xsl:when>
							<xsl:when test="contains(substring-after(releaseDate,' '),'Aug')">Aug</xsl:when>
							<xsl:when test="contains(substring-after(releaseDate,' '),'Sep')">Sep</xsl:when>
							<xsl:when test="contains(substring-after(releaseDate,' '),'Oct')">Oct</xsl:when>
							<xsl:when test="contains(substring-after(releaseDate,' '),'Nov')">Nov</xsl:when>
							<xsl:when test="contains(substring-after(releaseDate,' '),'Dec')">Dec</xsl:when>
						</xsl:choose>
					</xsl:variable>
						<xsl:value-of select="$month"/><xsl:text>. </xsl:text>
						<xsl:value-of select="substring-before(releaseDate,' ')"/><xsl:text>, </xsl:text>
						<xsl:value-of select="year"/>
				</xsl:if>
	</div>
	<div style="visibility:hidden">
		<xsl:attribute name="id">genre<xsl:value-of select="position()"/></xsl:attribute>
			<xsl:value-of select="$Genre"/>: 
				<xsl:if test="count(genres) != 0">
					<xsl:for-each select="genres/genre[position() &lt;= 1]">
						<xsl:choose>
							<xsl:when test="@index != ''">
								<xsl:value-of select="." /> 
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="." /> 
							</xsl:otherwise>
						</xsl:choose>
					</xsl:for-each>
				</xsl:if>
	</div>
	<div style="visibility:hidden">
		<xsl:attribute name="id">runtime<xsl:value-of select="position()"/></xsl:attribute>
			<xsl:value-of select="$Runtime"/>: 
				<xsl:if test="runtime != 'UNKNOWN'">
					<xsl:value-of select="runtime" /> 
				</xsl:if>
	</div>
	<div style="visibility:hidden">
		<xsl:attribute name="id">director<xsl:value-of select="position()"/></xsl:attribute>
			<xsl:value-of select="$Director"/>: 
				<xsl:if test="director != 'UNKNOWN'">
					<xsl:choose>
						<xsl:when test="director/@index != ''">
							<xsl:value-of select="director" /> 
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="director" />
						</xsl:otherwise>
					</xsl:choose>
				</xsl:if>
	</div>
	<div style="visibility:hidden">
		<xsl:attribute name="id">credits<xsl:value-of select="position()"/></xsl:attribute>
			<xsl:value-of select="$Credits"/>: 
				<xsl:if test="count(cast/actor) != 0">
					<xsl:for-each select="cast/actor[position() &lt;= 3]">
					<xsl:if test="position()!=1">, </xsl:if>
						<xsl:choose>
							<xsl:when test="@index != ''">
								<xsl:value-of select="." /> 
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="." /> 
							</xsl:otherwise>
						</xsl:choose>
					</xsl:for-each>
				</xsl:if>
	</div>
	<div style="visibility:hidden">
		<xsl:attribute name="id">plot<xsl:value-of select="position()"/></xsl:attribute>
			<xsl:value-of select="$Description"/>: 
				<xsl:choose>
					<xsl:when test="string-length(plot)&lt;275">
						<xsl:value-of select="plot"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="substring(plot,1,272)"/>...
					</xsl:otherwise>
				</xsl:choose>
    </div>

	<img width="211" height="159">
		<xsl:attribute name="src">
			<xsl:if test="fanartFile='UNKNOWN'">pictures/1x1.png</xsl:if>
			<xsl:if test="fanartFile!='UNKNOWN'"><xsl:value-of select="fanartFile"/></xsl:if>
		</xsl:attribute>
		<xsl:attribute name="id">fanart<xsl:value-of select="position()"/></xsl:attribute>
	</img>
	<img>
		<xsl:attribute name="src">pictures/glow.png</xsl:attribute>
		<xsl:attribute name="id">glow<xsl:value-of select="position()"/></xsl:attribute>
	</img>
</xsl:for-each>

</xsl:template>

<xsl:template match="movie">
	<xsl:param name="gap" />
	<xsl:param name="currentIndex" />
	<xsl:param name="lastIndex" />
	<xsl:param name="lastGap" />

<td align="center" valign="top" height="244">
	<a>
		<xsl:attribute name="onmouseover">show(<xsl:value-of select="position()+$gap"/>,"<xsl:value-of select="baseFilename"/>.playlist.jsp")</xsl:attribute>
		<xsl:attribute name="onmouseout">hide(<xsl:value-of select="position()+$gap"/>,"<xsl:value-of select="baseFilename"/>.playlist.jsp")</xsl:attribute>
		<xsl:attribute name="onfocus">show(<xsl:value-of select="position()+$gap"/>,"<xsl:value-of select="baseFilename"/>.playlist.jsp")</xsl:attribute>
		<xsl:attribute name="onblur">hide(<xsl:value-of select="position()+$gap"/>,"<xsl:value-of select="baseFilename"/>.playlist.jsp")</xsl:attribute>
			<xsl:attribute name="href">javascript:setParams('<xsl:value-of select="details"/>?"+0+","+genrecnt.toString()+","+alphaid.toString()+","+flag.toString()+",1,"+genreItems[1]+","+"0"+","+genreItems[1]+"');</xsl:attribute>
			<xsl:attribute name="TVID"><xsl:value-of select="position()+$gap"/></xsl:attribute>
<!--<xsl:attribute name="name"><xsl:value-of select="position()+$gap"/></xsl:attribute>-->
			<xsl:if test="$lastIndex != 0">
				<xsl:if test="$gap=0 and $currentIndex != 0">
					<xsl:attribute name="onkeyupset">pgup</xsl:attribute>
				</xsl:if>
				<xsl:if test="position()+$gap = 1">
					<xsl:attribute name="onkeyleftset">middle</xsl:attribute>
					<xsl:attribute name="name">first</xsl:attribute>
				</xsl:if>
				<xsl:if test="position()+$gap = 4">
					<xsl:attribute name="onkeyrightset">fifth</xsl:attribute>
				</xsl:if>
				<xsl:if test="position()+$gap = 5">
					<xsl:attribute name="name">fifth</xsl:attribute>
					<xsl:attribute name="onkeyleftset">middle</xsl:attribute>
				</xsl:if>
				<xsl:if test="position()+$gap = 8">
					<xsl:attribute name="onkeyrightset">first</xsl:attribute>
				</xsl:if>
				<xsl:if test="$gap=$lastGap and $currentIndex != $lastIndex">
					<xsl:attribute name="onkeydownset">pgdn</xsl:attribute>
				</xsl:if>
			</xsl:if>
			<img width="150" height="221">
				<xsl:attribute name="src"><xsl:value-of select="posterFile"/></xsl:attribute>
			</img>
	</a>
<!--<br/><xsl:value-of select="title"/>-->
</td>

</xsl:template>
</xsl:stylesheet>
